package com.xzl.xep.pojo;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.NotBlank;

import com.xzl.xep.common.utils.EncryptUtil;

@Entity
@Table(name="xt_operator")
public class Operator extends IdEntity {
	
	@NotBlank
	private String account;
	@NotBlank
	private String password;

	private String realName;
	
	@NotNull
	private Long companyId;
	
	private String companyName;
	private String img;

	@NotNull
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastLoginTime;
	
	private String lastLoginIp;

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRealName() {
		return realName;
	}

	public void setRealName(String realName) {
		this.realName = realName;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public String getLastLoginIp() {
		return lastLoginIp;
	}

	public void setLastLoginIp(String lastLoginIp) {
		this.lastLoginIp = lastLoginIp;
	}
	
	

	public Long getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Long companyId) {
		this.companyId = companyId;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public void encodePassword(){
		this.password = EncryptUtil.encrypt(password);
	}
	
	public boolean matchPassword(String inputPassword){
		return EncryptUtil.match(inputPassword,this.password );
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}
	
}
